home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
Snippets
/
PNL Libraries
/
MyFileSystemUtils.p
< prev
next >
Wrap
Text File
|
1997-04-05
|
21KB
|
816 lines
unit MyFileSystemUtils;
interface
uses
Types, Files, AppleTalk;
type
ScanProc = function(var fs:FSSpec; folder:boolean; path:Str255; var pb:CInfoPBRec):boolean;
{ for folders, return true to scan contents }
{ for files return true if you delete the file - other changes to the file system would be bad... }
procedure MyResolveAliasFile (var fs: FSSpec);
function MyGetCatInfo (vrn: integer; dirID: longint; var name: Str63; index: integer; var pb: CInfoPBRec): OSErr;
function FSpGetCatInfo (const fs: FSSpec; var pb: CInfoPBRec): OSErr;
function FSpGetIndCatInfo (var fs: FSSpec; index: integer; var pb: CInfoPBRec): OSErr;
function FSpSetCatInfo (const spec: FSSpec; var pb: CInfoPBRec): OSErr;
function FSpGetParID( const spec: FSSpec; var dirID: longint ): OSErr;
function FSpGetDirID( const spec: FSSpec; var dirID: longint ): OSErr;
function MyFSMakeFSSpec (vrn: integer; dirID: longint; name: Str255; var fs: FSSpec): OSErr;
procedure MyGetModDate (const spec: FSSpec; var moddate: longint);
function DuplicateFile (const org, new: FSSpec): OSErr;
function CopyData (src, dst: integer; len: longint): OSErr;
function TouchDir (fs: FSSpec): OSErr;
function TouchFolder (vrn: integer; dirID: longint): OSErr;
function CreateUniqueFile (var fs: FSSpec; creator, ftype: OSType): OSErr;
function CreateUniqueFolder (var fs: FSSpec; var dirID: longint ): OSErr;
function MyFSReadLineEOL (refnum: integer; ch: char; var s: Str255): OSErr;
function MyFSReadLine (refnum: integer; var s: Str255): OSErr;
function MyFSReadLineAt (refnum: integer; pos: longint; var s: Str255): OSErr;
function MyFSRead(refnum: integer; len: longint; p: Ptr): OSErr;
function MyFSWriteString( refnum: integer; const s: string ): OSErr;
function MyFSWrite (refnum: integer; len: longint; p: Ptr): OSErr;
function MyFSWriteAt (refnum: integer; mode: integer; pos, len: longint; p: Ptr): OSErr;
function MyFSReadAt (refnum: integer; pos, len: longint; p: Ptr): OSErr;
function MyFSReadFile( const spec: FSSpec; var data: Handle ): OSErr;
function FSSpecToFullPath (fs: FSSpec; var path: Str255): OSErr;
function DiskFreeSpace (vrn: integer): longint; { result in k }
function DiskSize (vrn: integer): longint; { result in k }
function BlessSystemFolder (vrn: integer; dirID: longint): OSErr;
function SameFSSpec (const fs1, fs2: FSSpec): boolean;
procedure GetSFLocation (var vrn: integer; var dirID: longint);
procedure SetSFLocation (vrn: integer; dirID: longint);
procedure SafeFindFolder (vRefNum: integer; folderType: OSType; var foundVRefNum: integer; var foundDirID: longint);
function CreateTemporaryFile (var fs: FSSpec): OSErr;
function GetDirID (wdrn: integer; var vrn: integer; var dirID: longint): OSErr;
function FSpGetFolderDirID( const spec: FSSpec; var dirID: longint ): OSErr;
function GetVolInfo (var name: Str63; var vrn: integer; index: integer; var CrDate: longint): OSErr;
function GetVolumeAddrBlock(vrn: integer; index: integer; var addr: AddrBlock): OSErr;
function ScanDirectory (fs: FSSpec; doit: ScanProc): OSErr;
function RemoveResourceFork( const spec: FSSpec ): OSErr;
implementation
uses
Memory, Files, Finder, Errors, TextUtils, OSUtils, Packages, GestaltEqu, Folders, Aliases, LowMem, Devices,
MyTypes, MyStrings, MyMemory, MyMathUtils;
procedure SafeFindFolder (vRefNum: integer; folderType: OSType; var foundVRefNum: integer; var foundDirID: longint);
var
theWorld: SysEnvRec;
gv: longint;
begin
foundVRefNum := -1;
foundDirID := 2;
if (Gestalt(gestaltFindFolderAttr, gv) <> noErr) | (not BTST(gv, gestaltFindFolderPresent)) | (FindFolder(vRefNum, folderType, true, foundVRefNum, foundDirID) <> noErr) then begin
if SysEnvirons(1, theWorld) = noErr then begin
foundVRefNum := theWorld.sysVRefNum;
foundDirID := 0;
end else begin
foundVRefNum := -1;
foundDirID := 2;
end;
end;
end;
function CreateTemporaryFile (var fs: FSSpec): OSErr;
begin
SafeFindFolder( kOnSystemDisk, kTemporaryFolderType, fs.vRefNum, fs.parID );
CreateTemporaryFile := CreateUniqueFile( fs, 'trsh', 'trsh' );
end;
procedure GetSFLocation (var vrn: integer; var dirID: longint);
begin
vrn:= -LMGetSFSaveDisk;
dirID:=LMGetCurDirStore;
end;
procedure SetSFLocation(vRefNum: integer; dirID: longint);
var
b21: Ptr;
sysVersion: longint;
begin
{ from Mark Romano @ Symantec: System 7.5 has a low-memory global that }
{ controls Standard File. To force it to use SFSaveDisk/CurDirStore, clear bit 3. }
if (Gestalt(gestaltSystemVersion, sysVersion) = noErr) & (sysVersion >= $0750) then begin
b21 := Pointer($0B21);
b21^ := BAND(b21^, GoodBNOT($04));
end;
LMSetSFSaveDisk(-vRefNum);
LMSetCurDirStore(dirID);
end;
function FSSpecToFullPath (fs: FSSpec; var path: Str255): OSErr;
var
err: OSErr;
pb: CInfoPBRec;
s: Str63;
begin
s := fs.name;
err := FSMakeFSSpec(fs.vRefNum, fs.parID, s, fs);
if err = fnfErr then begin
err := noErr;
end;
if err = noErr then begin
if fs.parID = 1 then begin
path := concat(fs.name, ':');
end else begin
path := fs.name;
while (err = noErr) & (fs.parID <> 1) do begin
err := FSpGetIndCatInfo(fs, -1, pb);
path := concat(fs.name, ':', path);
fs.parID := pb.ioFlParID;
end;
end;
end;
FSSpecToFullPath := err;
end;
function TouchDir (fs: FSSpec): OSErr;
var
pb: CInfoPBRec;
err: OSErr;
begin
if fs.name = '' then begin
TouchDir := TouchFolder(fs.vRefNum, fs.parID);
end else begin
pb.ioVRefNum := fs.vRefNum;
pb.ioDirID := fs.parID;
pb.ioNamePtr := @fs.name;
pb.ioFDirIndex := 0;
err := PBGetCatInfoSync(@pb);
if err = noErr then begin
pb.ioNamePtr := nil;
GetDateTime(pb.ioDrMdDat);
err := PBSetCatInfoSync(@pb);
end;
TouchDir := err;
end;
end;
function TouchFolder (vrn: integer; dirID: longint): OSErr;
var
pb: CInfoPBRec;
err: OSErr;
begin
pb.ioVRefNum := vrn;
pb.ioDirID := dirID;
pb.ioNamePtr := nil;
pb.ioFDirIndex := -1;
err := PBGetCatInfoSync(@pb);
if err = noErr then begin
pb.ioVRefNum := vrn;
pb.ioDirID := dirID;
pb.ioNamePtr := nil;
GetDateTime(pb.ioDrMdDat);
err := PBSetCatInfoSync(@pb);
end;
TouchFolder := err;
end;
function CreateUniqueFile (var fs: FSSpec; creator, ftype: OSType): OSErr;
var
oname: Str255;
n: Str255;
i: integer;
oe: OSErr;
begin
oname := fs.name;
LimitStringLength(oname, 27, '…');
oe := HCreate(fs.vRefNum, fs.parID, fs.name, creator, ftype);
i := 1;
while oe = dupFNErr do begin
NumToString(i, n);
fs.name := concat(oname, '#', n);
oe := HCreate(fs.vRefNum, fs.parID, fs.name, creator, ftype);
i := i + 1;
end;
CreateUniqueFile := oe;
end;
function CreateUniqueFolder (var fs: FSSpec; var dirID: longint ): OSErr;
var
oname: Str255;
n: Str255;
i: integer;
oe: OSErr;
begin
oname := fs.name;
LimitStringLength( oname, 27, '…' );
oe := FSpDirCreate( fs, 0, dirID );
i := 1;
while oe = dupFNErr do begin
NumToString( i, n );
fs.name := concat(oname, '#', n);
oe := FSpDirCreate( fs, 0, dirID );
i := i + 1;
end;
CreateUniqueFolder := oe;
end;
function MyFSReadAt (refnum: integer; pos, len: longint; p: Ptr): OSErr;
var
pb: ParamBlockRec;
oe: OSErr;
begin
pb.ioRefNum := refnum;
pb.ioBuffer := p;
pb.ioReqCount := len;
pb.ioPosMode := fsFromStart;
pb.ioPosOffset := pos;
oe := PBReadSync(@pb);
if (oe = noErr) & (pb.ioActCount <> len) then begin
oe := -1;
end;
MyFSReadAt := oe;
end;
function MyFSReadLineEOL (refnum: integer; ch: char; var s: Str255): OSErr;
var
pb: ParamBlockRec;
err: OSErr;
begin
pb.ioRefNum := refnum;
{$PUSH}
{$R-}
pb.ioBuffer := @s[1];
pb.ioReqCount := SizeOf(s) - 1;
pb.ioPosMode := fsFromMark + fsNewLine + BSL(ord(ch), 8);
pb.ioPosOffset := 0;
err := PBReadSync(@pb);
if (err = eofErr) & (pb.ioActCount > 0) then begin
err := noErr;
end;
if err = noErr then begin
if s[pb.ioActCount] = ch then begin
pb.ioActCount := pb.ioActCount - 1;
end;
s[0] := chr(pb.ioActCount);
end;
{$POP}
MyFSReadLineEOL := err;
end;
function MyFSReadLine (refnum: integer; var s: Str255): OSErr;
begin
MyFSReadLine := MyFSReadLineEOL(refnum, cr, s);
end;
function MyFSReadLineAt (refnum: integer; pos: longint; var s: Str255): OSErr;
var
pb: ParamBlockRec;
err: OSErr;
begin
pb.ioRefNum := refnum;
{$PUSH}
{$R-}
pb.ioBuffer := @s[1];
pb.ioReqCount := SizeOf(s) - 1;
pb.ioPosMode := fsFromStart + fsNewLine + BSL(ord(cr), 8);
pb.ioPosOffset := pos;
err := PBReadSync(@pb);
if (err = eofErr) & (pb.ioActCount > 0) then begin
err := noErr;
end;
if err = noErr then begin
s[0] := chr(pb.ioActCount - 1);
end;
{$POP}
MyFSReadLineAt := err;
end;
function MyFSRead(refnum: integer; len: longint; p: Ptr): OSErr;
var
err: OSErr;
count: longint;
begin
err := noErr;
if len > 0 then begin
count := len;
err := FSRead(refnum, count, p);
if (err = noErr) & (count <> len) then begin
err := -1;
end;
end;
MyFSRead := err;
end;
function MyFSWriteString( refnum: integer; const s: string ): OSErr;
begin
MyFSWriteString := MyFSWrite( refnum, length(s), @s[1] );
end;
function MyFSWrite (refnum: integer; len: longint; p: Ptr): OSErr;
var
oe: OSErr;
count: longint;
begin
oe := noErr;
if len > 0 then begin
count := len;
oe := FSWrite(refnum, count, p);
if (oe = noErr) & (count <> len) then begin
oe := -1;
end;
end;
MyFSWrite := oe;
end;
function MyFSReadFile( const spec: FSSpec; var data: Handle ): OSErr;
var
err, junk: OSErr;
rn: integer;
filelen: longint;
begin
data := nil;
err := FSpOpenDF( spec, fsRdPerm, rn );
if err = noErr then begin
err := GetEOF( rn, filelen );
if err = noErr then begin
err := MNewHandle( data, filelen );
if err = noErr then begin
HLock( data );
err := MyFSRead( rn, filelen, data^ );
HUnlock( data );
end;
end;
junk := FSClose( rn );
end;
if err <> noErr then begin
MDisposeHandle( data );
end;
MyFSReadFile := err;
end;
procedure MyResolveAliasFile (var fs: FSSpec);
var
isfolder, wasalias: boolean;
temp: FSSpec;
gv: longint;
oe: OSErr;
begin
if (Gestalt(gestaltAliasMgrAttr, gv) = noErr) & (BTST(gv, gestaltAliasMgrPresent)) then begin
temp := fs;
oe := ResolveAliasFile(fs, true, isfolder, wasalias);
if oe <> noErr then begin
fs := temp;
end;
end;
end;
function MyGetCatInfo (vrn: integer; dirID: longint; var name: Str63; index: integer; var pb: CInfoPBRec): OSErr;
begin
pb.ioVRefNum := vrn;
pb.ioDirID := dirID;
pb.ioNamePtr := @name;
pb.ioFDirIndex := index;
MyGetCatInfo := PBGetCatInfoSync(@pb);
end;
function FSpGetParID( const spec: FSSpec; var dirID: longint ): OSErr;
var
err: OSErr;
pb: CInfoPBRec;
begin
err := FSpGetCatInfo( spec, pb );
if err = noErr then begin
dirID := pb.ioDrParID;
end;
FSpGetParID := err;
end;
function FSpGetDirID( const spec: FSSpec; var dirID: longint ): OSErr;
var
err: OSErr;
pb: CInfoPBRec;
begin
err := FSpGetCatInfo( spec, pb );
if err = noErr then begin
if pb.ioFlAttrib and ioDirMask <> 0 then begin
dirID := pb.ioDrDirID;
end else begin
err := fnfErr;
end;
end;
FSpGetDirID := err;
end;
function FSpGetCatInfo (const fs: FSSpec; var pb: CInfoPBRec): OSErr;
begin
pb.ioVRefNum := fs.vRefNum;
pb.ioDirID := fs.parID;
pb.ioNamePtr := @fs.name;
pb.ioFDirIndex := 0;
FSpGetCatInfo := PBGetCatInfoSync(@pb);
end;
function FSpGetIndCatInfo (var fs: FSSpec; index: integer; var pb: CInfoPBRec): OSErr;
begin
pb.ioVRefNum := fs.vRefNum;
pb.ioDirID := fs.parID;
pb.ioNamePtr := @fs.name;
pb.ioFDirIndex := index;
FSpGetIndCatInfo := PBGetCatInfoSync(@pb);
end;
function FSpSetCatInfo (const spec: FSSpec; var pb: CInfoPBRec): OSErr;
begin
pb.ioVRefNum := spec.vRefNum;
pb.ioDirID := spec.parID;
pb.ioNamePtr := @spec.name;
FSpSetCatInfo := PBSetCatInfoSync(@pb);
end;
function MyFSMakeFSSpec (vrn: integer; dirID: longint; name: Str255; var fs: FSSpec): OSErr;
var
pb: CInfoPBRec;
oe: OSErr;
gv: longint;
begin
if (Gestalt(gestaltFSAttr, gv) = noErr) & (BTST(gv, gestaltHasFSSpecCalls)) then begin
oe := FSMakeFSSpec(vrn, dirID, name, fs);
end else begin
oe := MyGetCatInfo(vrn, dirID, name, 0, pb);
if (oe = noErr) then begin
fs.vRefNum := pb.ioVRefNum;
fs.parID := pb.ioFlParID;
fs.name := name;
end;
end;
MyFSMakeFSSpec := oe;
end;
procedure MyGetModDate (const spec: FSSpec; var moddate: longint);
var
err: OSErr;
pb: CInfoPBRec;
begin
err := FSpGetCatInfo( spec, pb );
if err = noErr then begin
moddate := pb.ioFlMdDat
end else begin
moddate := $80000000;
end;
end;
function CopyData (src, dst: integer; len: longint): OSErr;
const
buffer_len = 4096;
var
buffer: array[1..buffer_len] of SignedByte;
l: longint;
oe: OSErr;
begin
oe := noErr;
while (len > 0) & (oe = noErr) do begin
if len > SizeOf(buffer) then begin
l := SizeOf(buffer);
end else begin
l := len;
end;
oe := FSRead(src, l, @buffer);
if (l = 0) & (oe = noErr) then begin
oe := -1;
end;
if oe = noErr then begin
oe := MyFSWrite(dst, l, @buffer);
end;
len := len - l;
end;
CopyData := oe;
end;
function DuplicateFile (const org, new: FSSpec): OSErr;
const
fdInited = $0100;
var
oe, ooe: OSErr;
fi: FInfo;
pb: CInfoPBRec;
orn, nrn: integer;
rlen, dlen: longint;
begin
oe := FSpGetFInfo(org, fi);
if oe = noErr then begin
oe := FSpCreate(new, fi.fdCreator, fi.fdType, 0);
fi.fdFlags := band(fi.fdFlags, GoodBNOT(fdInited));
oe := FSpSetFInfo(new, fi);
end;
if oe = noErr then begin
oe := FSpGetCatInfo(org, pb);
if oe = noErr then begin
dlen := pb.ioFlLgLen;
rlen := pb.ioFlRLgLen;
oe := FSpSetCatInfo( new, pb);
end;
if oe = noErr then begin
oe := FSpOpenDF(org, fsRdPerm, orn);
if oe = noErr then begin
oe := FSpOpenDF(new, fsWrPerm, nrn);
if oe = noErr then begin
oe := CopyData(orn, nrn, dlen);
ooe := FSClose(nrn);
if oe = noErr then begin
ooe := oe;
end;
end;
ooe := FSClose(orn);
end;
end;
if oe = noErr then begin
oe := FSpOpenRF(org, fsRdPerm, orn);
if oe = noErr then begin
oe := FSpOpenRF(new, fsWrPerm, nrn);
if oe = noErr then begin
oe := CopyData(orn, nrn, rlen);
ooe := FSClose(nrn);
if oe = noErr then begin
ooe := oe;
end;
end;
ooe := FSClose(orn);
end;
end;
if oe <> noErr then begin
ooe := FSpDelete(new);
end;
end;
DuplicateFile := oe;
end;
function MyFSWriteAt (refnum: integer; mode: integer; pos, len: longint; p: Ptr): OSErr;
var
pb: ParamBlockRec;
oe: OSErr;
begin
pb.ioRefNum := refnum;
pb.ioBuffer := p;
pb.ioReqCount := len;
pb.ioPosMode := mode;
pb.ioPosOffset := pos;
oe := PBWriteSync(@pb);
if (oe = noErr) & (pb.ioActCount <> len) then begin
oe := -1;
end;
MyFSWriteAt := oe;
end;
const
maxk = $70000000 div 1024;
function MultiplyAllocation (blocks, blocksize: longint): longint; { result in k }
var
size: longint;
begin
blocks := BAND(BSR(blocks, 1), $00007FFF); { div 2 }
blocksize := BAND(BSR(blocksize, 9), $007FFFFF); { div 512 }
if (blocksize > 256) & (blocks > 256) then begin
size := (blocksize div 16) * (blocks div 16);
if size > maxk div 256 then begin
size := maxk div 256;
end;
size := size * 256;
end else begin
size := blocksize * blocks; { in k }
if size > maxk then begin
size := maxk;
end;
end;
MultiplyAllocation := size;
end;
function OldDiskFreeSpace (vrn: integer): longint; { result in k }
var
err: OSErr;
pb: HParamBlockRec;
free: longint;
begin
free := maxk;
pb.ioNamePtr := nil;
pb.ioVRefNum := vrn;
pb.ioVolIndex := 0;
err := PBHGetVInfoSync(@pb);
if err = noErr then begin
free := MultiplyAllocation(pb.ioVFrBlk, pb.ioVAlBlkSiz);
end;
OldDiskFreeSpace := free;
end;
function DiskFreeSpace (vrn: integer): longint; { result in k }
var
err: OSErr;
free: longint;
begin
err := GetVInfo(vrn, nil, vrn, free);
if err <> noErr then begin
free := maxk;
end else begin
if free < 0 then begin
free := maxk;
end else begin
free := free div 1024;
if free > maxk then begin
free := maxk;
end;
end;
end;
DiskFreeSpace := free;
end;
function DiskSize (vrn: integer): longint; { result in k }
var
err: OSErr;
pb: HParamBlockRec;
size: longint;
begin
size := 0;
pb.ioNamePtr := nil;
pb.ioVRefNum := vrn;
pb.ioVolIndex := 0;
err := PBHGetVInfoSync(@pb);
if err = noErr then begin
size := MultiplyAllocation(pb.ioVNmAlBlks, pb.ioVAlBlkSiz);
end;
DiskSize := size;
end;
function BlessSystemFolder (vrn: integer; dirID: longint): OSErr;
var
err: OSErr;
pb: HParamBlockRec;
begin
pb.ioNamePtr := nil;
pb.ioVRefNum := vrn;
pb.ioVolIndex := 0;
err := PBHGetVInfoSync(@pb);
if err = noErr then begin
pb.ioVFndrInfo[1] := dirID; { ARGHHHHHHH! }
err := PBSetVInfoSync(@pb);
end;
BlessSystemFolder := err;
end;
function SameFSSpec (const fs1, fs2: FSSpec): boolean;
begin
SameFSSpec := (fs1.vRefNum = fs2.vRefNum) & (fs1.parID = fs2.parID) & (IUEqualString(fs1.name, fs2.name) = 0);
end;
function GetDirID (wdrn: integer; var vrn: integer; var dirID: longint): OSErr;
var
procID: longint;
oe: OSErr;
begin
oe := GetWDInfo(wdrn, vrn, dirID, procID);
if oe <> noErr then begin
vrn := wdrn;
dirID := 0;
end;
GetDirID := oe;
end;
function FSpGetFolderDirID( const spec: FSSpec; var dirID: longint ): OSErr;
var
err: OSErr;
pb: CInfoPBRec;
begin
dirID := -10;
err := FSpGetCatInfo( spec, pb );
if err = noErr then begin
if (pb.ioFlAttrib and ioDirMask) = 0 then begin
err := fnfErr;
end else begin
dirID := pb.ioDrDirID;
end;
end;
FSpGetFolderDirID := err;
end;
function GetVolInfo (var name: Str63; var vrn: integer; index: integer; var CrDate: longint): OSErr;
var
pb: ParamBlockRec;
oe: OSErr;
begin
if (name <> '') & (name[length(name)] <> ':') then begin
name := concat(name, ':');
end;
pb.ioNamePtr := @name;
pb.ioVRefNum := vrn;
pb.ioVolIndex := index;
oe := PBGetVInfoSync(@pb);
if oe = noErr then begin
vrn := pb.ioVRefNum;
CrDate := pb.ioVCrDate;
end;
GetVolInfo := oe;
end;
{$PUSH}
{$ALIGN MAC68K}
type
VolParamsRecord = packed record
version: integer;
attrib: longint;
localhand: Handle;
address: AddrBlock;
end;
{$ALIGN RESET}
{$POP}
function GetVolumeAddrBlock(vrn: integer; index: integer; var addr: AddrBlock): OSErr;
var
err: OSErr;
pb: HParamBlockRec;
volparams: VolParamsRecord;
begin
longint(addr) := 0;
pb.ioNamePtr := nil;
pb.ioVRefNum := vrn;
pb.ioVolIndex := index;
err := PBHGetVInfoSync(@pb);
if err = noErr then begin
pb.ioNamePtr := nil;
pb.ioBuffer := @volparams;
pb.ioReqCount := SizeOf(volparams);
err := PBHGetVolParmsSync(@pb);
end;
if err = noErr then begin
addr := volparams.address;
end;
GetVolumeAddrBlock := err;
end;
function ScanDirectory (fs: FSSpec; doit: ScanProc): OSErr;
var
pb: CInfoPBRec;
ret, folder: boolean;
path: Str255;
procedure Scan (dirID: longint);
var
index, len: integer;
oe: OSErr;
begin
index := 1;
repeat
with pb do begin
oe := MyGetCatInfo(fs.vRefNum, dirID, fs.name, index, pb);
index := index + 1;
if oe = noErr then begin
fs.parID := dirID;
folder := BAND(pb.ioFlAttrib, ioDirMask) <> 0;
ret := doit(fs, folder, path, pb);
if folder and ret then begin
len := length(path);
path := concat(path, fs.name, ':');
Scan(pb.ioDirID);
path[0] := chr(len);
end else if not folder and ret then begin
index := index - 1;
end;
end;
end;
until oe <> noErr;
end;
var
err: OSErr;
dummy: boolean;
begin
path := ':';
if fs.name <> '' then begin
err := FSpGetCatInfo(fs, pb);
if err = noErr then begin
if BAND(pb.ioFlAttrib, ioDirMask) <> 0 then begin
Scan(pb.ioDirID);
end else begin
dummy := doit(fs, false, path, pb);
end;
end;
end else begin
Scan(fs.parID);
err := noErr;
end;
ScanDirectory := err;
end;
function RemoveResourceFork( const spec: FSSpec ): OSErr;
var
err, err2: OSErr;
refnum: integer;
begin
err:=FSpOpenRF( spec, fsRdWrPerm, refnum );
if err = noErr then begin
err := SetEOF( refnum, 0 );
err2 := FSClose( refnum );
if err = noErr then begin
err := err2;
end;
end;
RemoveResourceFork := err;
end;
end.